package com.study.entity;


import com.fasterxml.jackson.annotation.JsonProperty;
import com.study.shiro.ShiroUtils;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * 系统用户
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class SysUserEntity implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 用户ID
     */

    private Long userId;

    /**
     * 用户名
     */
    private String username;

    /**
     * 密码
     */
    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
    private String password;

    /**
     * 权限
     */
    private String permission;

    /**
     * 盐
     */
    private String salt;

    public SysUserEntity(Long userId, String username, String password, String permission) {
        this.userId = userId;
        this.username = username;
        this.permission = permission;
        this.salt = this.getUsername().substring(0,3);
        this.password = ShiroUtils.sha256(password, this.salt);
    }

}
